package com.example.litterpainterdemo.guide

import android.content.Context
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.edit
import androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback
import com.example.litterpainterdemo.databinding.FragmentGuideBinding
import com.example.litterpainterdemo.utils.Constants
import com.example.litterpainterdemo.utils.SPUtils


class GuideFragment : Fragment() {
    private lateinit var binding:FragmentGuideBinding


    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = FragmentGuideBinding.inflate(inflater,container,false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
       // SPUtils.getInstance(requireContext()).isFirst = false

        val vp2 = binding.viewPager2
        vp2.adapter = GuideAdapter(
            listOf(GuideOneFragment(),GuideTwoFragment(),GuideThreeFragment(),GuideFourFragment()),
            parentFragmentManager,
            lifecycle
        )


        //监听当前是哪页标签页
        vp2.registerOnPageChangeCallback(object: OnPageChangeCallback(){
            override fun onPageSelected(position: Int) {
                super.onPageSelected(position)
                binding.indicatorView.changeSelect(position)
            }
        })



    }




}